//
//  StoreDetailSubscribeView.m
//  BaseProject
//
//  Created by 王洋 on 2020/8/14.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "StoreDetailSubscribeView.h"

@implementation StoreDetailSubscribeView

- (void)dealloc {
    NSLog(@"StoreDetailSubscribeView dealloc");
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    WEAKSELF
    [self.arriveTimeControl addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        
        [weakSelf endEditing:YES];
        if (weakSelf.StoreDetailSubscribeBlock) {
            weakSelf.StoreDetailSubscribeBlock(StoreDetailSubscribeViewActionType_selTime);
        }
    }];
}

- (void)clearView {
    self.nameTF.text = @"";
    self.phoneTF.text = @"";
    self.arriveTimeLab.text = @"";
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    WEAKSELF
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [weakSelf pp_clipCorners:UIRectCornerTopLeft|UIRectCornerTopRight radius:10];
        [weakSelf.handleBtn pp_clipCorners:UIRectCornerAllCorners radius:weakSelf.handleBtn.frame.size.height/2];
    });
}

- (IBAction)handleAction:(id)sender {
    
    if (self.nameTF.text.length == 0) {
        [SVProgressHUD showErrorWithStatus:@"请输入姓名"];
        [SVProgressHUD dismissWithDelay:1];
        return;
    }
    if (self.phoneTF.text.length == 0) {
        [SVProgressHUD showErrorWithStatus:@"请输入手机号"];
        [SVProgressHUD dismissWithDelay:1];
        return;
    }
    if (self.phoneTF.text.length !=11 || ![Utilities checkPhoneTel:self.phoneTF.text]) {
        [SVProgressHUD showErrorWithStatus:@"请输入正确的手机号"];
        [SVProgressHUD dismissWithDelay:1];
        return;
    }
    
    if (self.StoreDetailSubscribeBlock) {
        self.StoreDetailSubscribeBlock(StoreDetailSubscribeViewActionType_handle);
    }
}


@end
